package com.itheima.customer.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.itheima.customer.dao.BaseDao;

@Repository
public class BaseDaoImpl<T> implements BaseDao<T> {

	@Autowired
	private HibernateTemplate hibernateTemplate;
	
	@Override
	public void save(T t) {
		
	}

	@Override
	public List<T> findAll(DetachedCriteria dCriteria) {
		
		return (List<T>) hibernateTemplate.findByCriteria(dCriteria);
	}

	/*@Override
	public T findCustomer(T t) {
		return hibernateTemplate.load(entityClass, id);
	}*/

	@Override
	public void update(T t) {
		hibernateTemplate.update(t);
	}

	@Override
	public void delete(T t) {
		hibernateTemplate.delete(t);
	}

	/*@Override
	public List<T> findAllCustomers() {
		return hibernateTemplate.find(queryString, values);
	}*/
/*
	@Override
	public T findCustomerById(Long id) {
		return null;
	}*/

}
